﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Xml;
using System.Xml.Serialization;


namespace SusyGame_Model
{
    [Serializable]
    public class Weapon : Sprite
    {
        //Atributos
        private int damage;
        private int age;
        private int speed;
        
        public int Age
        {
            get { return age; }
            set { age = value; }
        }
        
        public int Damage
        {
            get { return damage; }
            set { damage = value; }
        }   

        public int Speed
        {
            get { return speed; }
            set { speed = value; }
        }

        //Constructores
        public Weapon()
        {
        }

        public bool IsDead()
        {
            return age > 100;
        }

        public Weapon(Texture2D texture, Vector2 position, float rotation, int speed, int damage) : base(texture, position)
        {
            this.rotation = rotation;
            this.damage = damage;
            this.speed = speed;
        }

        public Weapon(Texture2D texture, Vector2 position, Vector2 velocity, int speed, int damage)
            : base(texture, position)
        {
            this.rotation = rotation;
            this.damage = damage;
            this.speed = speed;
            this.velocity = velocity * speed;
        }

        public void Kill()
        {
            this.age = 200;
        }

        public override void Update(GameTime gameTime)
        {
            age++;
            position += velocity;

            base.Update(gameTime);
        }

        public void SetRotation(float value)
        {
            rotation = value;

            velocity = Vector2.Transform(new Vector2(0, -speed),
                Matrix.CreateRotationZ(rotation));
        }
    }
}
